#include <string>

// Forward declarations
//class FILE;

namespace ePuck
{
  struct SProximity
  {
    unsigned S0;
    unsigned S1;
    unsigned S2;
    unsigned S3;
    unsigned S4;
    unsigned S5;
    unsigned S6;
    unsigned S7;

    SProximity( )
    : S0( 0 )
    , S1( 0 )
    , S2( 0 )
    , S3( 0 )
    , S4( 0 )
    , S5( 0 )
    , S6( 0 )
    , S7( 0 )
    {
      ;
    }
  };

  enum EResult
  {
    EResultOk,
    EResultUnableToOpenDevice,
    EResultDeviceNotConnected,
    EResultUnableToWriteToDevice,

    EResultFail
  };
  
  enum ESound
  {
    ESoundOff,
    ESoundEuh,
    ESoundBang,
    ESoundAuw,
    ESoundYouw,
    ESoundWheeeh,
    ESoundUnknown
  };

  enum ELedId
  {
    ELedIdBody = 'B',
    ELedIdFront = 'F',
    ELedIdUnknown
  };

  enum ELedState
  {
    ELedStateOff,
    ELedStateOn,
    ELedStateInverse,
    ELedStateUnknown
  };

  class Device
  {
    private: 
      FILE* mpConnectionHandle;
      bool  mConnected;
      
      void LimitMotorSpeed( signed& rValue );

      EResult CheckInitialization( void );

      EResult SendCommand( const char* format, ... );

    public:
      Device( void );

      ~Device( void );
      
      EResult Connect(  const std::string& rDevice );
      
      EResult Move(     const signed Left, 
                        const signed Right );

      EResult Sound(    const ESound Sound );

      EResult Reset(    void );

      EResult Stop(     void );
      
      EResult SetLed(   const ELedId Led, const ELedState State );

      EResult GetProximity( SProximity& rProximity );

      FILE* GetHandle( void );
  };
}
